package cn.ococci.dm.Main.Tools;

import android.widget.Toast;

import cn.ococci.dm.Base.ActivityStack;
import cn.ococci.dm.Base.BaseApp;


/**
 * Created by cyan on 15/9/21.
 * 弹出提示框
 */
public class ToastTool {

    public static void showShortTime(String content){
        Toast.makeText(BaseApp.getInstance(),content,Toast.LENGTH_SHORT).show();
    }
    public static void showShortTime(int resId){
        Toast.makeText(BaseApp.getInstance(), BaseApp.findResIdDecoderString(resId),Toast.LENGTH_SHORT).show();
    }

    public static void showLongTime(String content){
        Toast.makeText(BaseApp.getInstance(),content,Toast.LENGTH_LONG).show();
    }

    public static void showLongTime(int resId){
        Toast.makeText(BaseApp.getInstance(), BaseApp.findResIdDecoderString(resId),Toast.LENGTH_LONG).show();
    }

    /**
     * 弹出toast(次序短时间)
     *
     * @param text
     */
    public static void show(String text) {
        Toast.makeText(BaseApp.getInstance(), text, Toast.LENGTH_SHORT).show();
    }

    public static void show(int resId) {
        Toast.makeText(BaseApp.getInstance(), resId, Toast.LENGTH_SHORT).show();
    }

    public static void showOnUiThread(final String text) {
        ActivityStack.currentActivity().runOnUiThread(new Runnable() {
            public void run() {
                show(text);
            }
        });
    }

    public static void showOnUiThread(final int  resId) {
        ActivityStack.currentActivity().runOnUiThread(new Runnable() {
            public void run() {
                show(resId);
            }
        });
    }

    /**
     * 弹出toast(持续较长时间)
     *
     * @param text
     */
    public static void showLong(String text) {

        Toast.makeText(BaseApp.getInstance(), text, Toast.LENGTH_LONG).show();
    }

    public static void showOnSubThread(int crash_toast) {
    }

}
